package com.quarters.controller.admin;


import com.fasterxml.jackson.databind.ser.Serializers;
import com.quarters.bean.Inquiry;
import com.quarters.bean.Quarters;
import com.quarters.bean.layuiBean.ResultPage;
import com.quarters.bean.layuiBean.VoPage;
import com.quarters.commen.BaseController;
import com.quarters.util.Respons.ResponseUtil;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * <p>
 * 报修查询表 前端控制器
 * </p>
 *
 * @author 冯政尚
 * @since 2019-09-02
 */
@Controller
@RequestMapping("admin/inquiry")
public class InquiryController extends BaseController {

    /**
     * @param voPage
     * @return 后台查询
     */
    @RequestMapping(value = "selectMyPage",method = RequestMethod.GET)
    @ResponseBody
    public ResultPage<Inquiry> selectMyPage(VoPage voPage, HttpSession session){
        if(getUserInfo(session).getUsername().equals("admin")){
            return inquiryService.selectMyPageAll(voPage);
        }
        return inquiryService.selectMyPage(voPage,getUserInfo(session).getId());
    }



    /**
     * @param inquiry
     * @return 删除
     */
    @RequestMapping(value = "deleteByIdInquiry",method = RequestMethod.POST)
    @ResponseBody
    public Map deleteByIdInquiry(@RequestBody Inquiry inquiry){
        if(inquiryService.removeById(inquiry)){
            return ResponseUtil.getSuccessMap();
        }
        return ResponseUtil.getExceptionMap();
    }

}
